package com.znxs.zuopao_c.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;

@Configuration
public class RedisTemplateConfig {

    @Bean
    public RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory connectionFactory){
        // 创建redis实例
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        // 指定连接工厂
        redisTemplate.setConnectionFactory(connectionFactory);
        // 指定key序列化工具 (原生序列化)
        redisTemplate.setKeySerializer(RedisSerializer.string());
        return redisTemplate;
    }

}
